# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.
#
# This PKGBUILD was extracted from AUR and adapted to our style.
# AUR Maintainer: Marcell Meszaros < marcell.meszaros AT runbox.eu >
# AUR Contributor: max-k <max-kATpostDOTcom>

pkgname=sonar-scanner
pkgver=6.2.1.4610
pkgrel=3
pkgdesc='Generic CLI tool to launch project analysis on SonarQube servers.'
groups=('blackarch' 'blackarch-code-audit')
arch=('any')
url='https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/'
license=('LGPL3')
depends=('java-runtime' 'sh')
backup=("opt/$pkgname/conf/$pkgname.properties")
source=("https://binaries.sonarsource.com/Distribution/$pkgname-cli/$pkgname-cli-$pkgver.zip"
        "$pkgname.sh"
        "$pkgname.install")
install="$pkgname.install"
sha512sums=('4da4447df630270738ee0a803bfd1d081e0c29a0783572eebada186dd808f2fd26b60de29df9cb6d284279cad215a708d3678aee8dbcbbe1f8f924ac2a267372'
            'd31374e9cf8a7e814655b1e4dca0496e90f973b87df056fa84756b4824cd59dabe0dcf4419f0ff6428e3cb43707d6586be07ec7de31d9c39a828bb18808d0fcd'
            'a2dd582487e9f8b8a33e0865a40636635efdfe2cf9dad71ce45cd55019236fd78f75fb56b63e0c0b1366f9a32b591bf82f65f28e3492106cd1f8772cc961b780')

package() {
  cd "$pkgname-$pkgver"

  install -dm 755 "$pkgdir/usr/bin"

  install -Dm 755 -t "$pkgdir/etc/profile.d/" "$srcdir/$pkgname.sh"
  install -Dm 755 -t "$pkgdir/opt/$pkgname/bin/" "bin/$pkgname"
  install -Dm 644 -t "$pkgdir/opt/$pkgname/lib/" "lib/$pkgname-cli-$pkgver.jar"
  install -Dm 644 -t "$pkgdir/opt/$pkgname/conf/" \
    "conf/sonar-scanner.properties"

  ln -sf "/opt/$pkgname/conf" "$pkgdir/etc/$pkgname"

  ln -sf "/opt/$pkgname/bin/$pkgname" "$pkgdir/usr/bin/$pkgname"
}

